package com.liyunc.toolset;

/**
 * Copyright (c) 2018-2023 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 */

import java.util.function.Function;

/**
 * @author liyuncong
 * @version 1.0
 * @file CmdArgItem
 * @brief CmdArgItem
 * @details CmdArgItem
 * @date 2023-02-16
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2023-02-16                  liyuncong          Created
 */
public class CmdArgItem<T> {
    private String argName;
    private CmdArgType argType;
    private T defaultValue;
    private Function<String, T> parseMethod;
    private Integer maxOccurs = 1;

    public T parse(String value) {
        return parseMethod.apply(value);
    }

    public String getArgName() {
        return argName;
    }

    public void setArgName(String argName) {
        this.argName = argName;
    }

    public CmdArgType getArgType() {
        return argType;
    }

    public void setArgType(CmdArgType argType) {
        this.argType = argType;
    }

    public T getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(T defaultValue) {
        this.defaultValue = defaultValue;
    }

    public Function<String, T> getParseMethod() {
        return parseMethod;
    }

    public void setParseMethod(Function<String, T> parseMethod) {
        this.parseMethod = parseMethod;
    }

    public Integer getMaxOccurs() {
        return maxOccurs;
    }

    public void setMaxOccurs(Integer maxOccurs) {
        this.maxOccurs = maxOccurs;
    }
}
